package com.up.blog.service;

import com.up.blog.domain.PageInfo;
import com.up.blog.domain.Fansbean;
import com.up.blog.mapper.GetFansMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
@Service("getFansService")
public class GetFansService {
//    InputStream conf = Resources.getResourceAsStream("SqlMapConfig.xml");
//    //创建会话工厂
//    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(conf);
//    //使用会话工厂创建会话对象
//    SqlSession sqlSession = sqlSessionFactory.openSession(true);
//    GetFansMapper mapper = sqlSession.getMapper(GetFansMapper.class);
@Autowired
private GetFansMapper mapper;
    public GetFansService() throws IOException {
    }
    public Long getCount() throws SQLException {
        return mapper.getCount();
    }
    public List<Fansbean> getFansbean(Integer page, Integer limit) throws SQLException {
        Integer curCount=(page-1)* limit;
        PageInfo pageInfo=new PageInfo();
        pageInfo.setCurCount(curCount);
        pageInfo.setLimit(limit);
        return mapper.getFansbean(pageInfo);
    }
}
